<form id="versionGroupForm" lay-filter="versionGroupForm" class="layui-form model-form">
    <div class="layui-form-item layui-row">
        <div class="layui-inline layui-col-md12">
            <label class="layui-form-label">版本值:</label>
            <div class="layui-input-block">
                <input name="ckName" type="text" placeholder="请输入版本值" class="layui-input"
                       lay-verType="tips" lay-verify="required" required/>
            </div>
            <label class="layui-form-label">版本备注:</label>
            <div class="layui-input-block">
                <input name="ckYm" type="text" placeholder="请输入版本备注" class="layui-input"
                       lay-verType="tips" lay-verify="required" required/>
            </div>
            <button class="layui-btn layui-btn-primary layui-btn-sm" type="button" ew-event="addVersion">添加版本</button>
        </div>
    </div>
</form>
<div class="layui-form-item layui-row mode-version-table" >
    <table class="layui-table" id="identGroupVersionTable" lay-filter="identGroupVersionTable" lay-skin="nob"></table>
</div>

<!-- 分组版本表格操作列DOM -->
<script type="text/html" id="ident-group-version-tableHandle-box">
    <a class="layui-btn layui-btn-xs layui-btn-warning" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="delete">删除</a>
</script>

<!-- 修改版本弹窗 -->
<script type="text/html" id="model-edit-version">
    <form id="editGroupVersionForm" lay-filter="editGroupForm" class="layui-form model-form">
        <input name="userId" type="hidden"/>
        <div class="layui-form-item">
            <label class="layui-form-label">名称</label>
            <div class="layui-input-block">
                <input name="nickName" placeholder="请输入用户名" type="text" class="layui-input" maxlength="20"
                       lay-verType="tips" lay-verify="required" required/>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">描述:</label>
            <div class="layui-input-block">
                        <textarea name="hlbz" placeholder="请输入衡量标准" class="layui-textarea"
                                  lay-verType="tips" lay-verify="required" required></textarea>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary layui-btn-sm" type="button" ew-event="closePageDialog">取消</button>
            <button class="layui-btn layui-btn-sm" lay-filter="modelSubmitVersion" lay-submit >确定</button>
        </div>
    </form>
</script>

<script>
    layui.use(['layer', 'form', 'admin','table'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var admin = layui.admin;
        var table = layui.table;

        var mUser = window.mSelUser;  // 列表页面传递的数据，也可以使用top.xxx

        // 表单提交事件
        form.on('submit(addIdentValueForm)', function (data) {

        });

        renderTable();


        // 工具条点击事件
        table.on('tool(identGroupVersionTable)', function (obj) {
            var data = obj.data;
            var layEvent = obj.event;
            if (layEvent === 'edit') { // 修改
                showEditModel(data);
            } else if (layEvent === 'delete') { // 删除
                showDeleteModel(data);
            }
        });

        function renderTable() {
            table.render({
                elem: '#identGroupVersionTable',
                size: 'sm', //小尺寸的表格
                skin:'nob',
                url: '../../json/user.json',
                page: false,
                cellMinWidth: 100,
                cols: [[
                    {type:'numbers', title: '#'},
                    {field: 'username', align: 'center', title: '值'},
                    {field: 'nickName', align: 'center', title: '备注'},
                    {align: 'center', toolbar: '#ident-group-version-tableHandle-box', title: '操作', minWidth: 120}
                ]]
            });
        }

        function showEditModel() {
            layui.use(['admin'], function () {
                var $ = layui.jquery;
                var admin = layui.admin;
                var form = layui.form;
                admin.open({
                    type: 1,
                    title: '编辑分组',
                    offset: "auto",
                    content: $('#model-edit-version').html(),
                    success: function (layero, dIndex) {
                        console.log(layero)
                        console.log(dIndex)
                        // var url = mUser ? '/updateUser' : '/addUser';
                        // // 回显数据
//                        form.val('editGroupForm', data);
                        // // 表单提交事件
                        // form.on('submit(modelSubmitUser)', function (data) {
                        //     layer.load(2);
                        //     $.post(url, data.field, function (res) {
                        //         layer.closeAll('loading');
                        //         if (res.code == 200) {
                        //             layer.close(dIndex);
                        //             layer.msg(res.msg, {icon: 1});
                        //             insTb.reload();
                        //         } else {
                        //             layer.msg(res.msg, {icon: 2});
                        //         }
                        //     }, 'json');
                        //     return false;
                        // });
                    }
                });
            })
        }

        function showDeleteModel() {
            parent.layer.confirm('确认删除吗？', {
                skin: 'layui-layer-admin',
                size:'sm',
                shade: .1
            }, function (index) {
                console.log(index)
                parent.layer.close(index);
            });
        }

    });
</script>

<style>
    .mode-version-table{
        margin-bottom: 20px;
    }
</style>